﻿<%@ Page Title="" Language="VB" MasterPageFile="~/MasterPageContent.master" AutoEventWireup="false" CodeFile="Item.aspx.vb" Inherits="Setup_Item" %>

<%@ Register Src="~/UserControls/DDL.ascx" TagName="DoubleFilteredDropDownList"
    TagPrefix="uc1" %>
<%@ Register Src="~/UserControls/OneFilteredDropDownList.ascx" TagName="OneFilteredDropDownList"
    TagPrefix="uc2" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register TagPrefix="sds" Namespace="Telerik.Web.SessionDS" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="HeaderPlaceHolder" Runat="Server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">





    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgItem">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgItem" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Office2010Blue"
        Transparency="20">
    </telerik:RadAjaxLoadingPanel>

        <br /><br />

        <telerik:RadGrid ID="rgItem" runat="server" GridLines="None" DataSourceID="odsItem"
            AllowAutomaticDeletes="True" AllowAutomaticInserts="True" 
            Width="100%" AllowAutomaticUpdates="True" AllowPaging="True"
            AutoGenerateColumns="False"  MasterTableView-Dir="<%$ Resources:SystemResource, HTMLDirectionality %>"
            GroupPanel-Text="<%$ Resources:MainGrid ,GroupPanelText %>" 
            CellSpacing="0">
            <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom" DataKeyNames="ItemID"
                TableLayout="Fixed" DataSourceID="odsItem" HorizontalAlign="NotSet"
                NoMasterRecordsText="<%$ Resources:MainGrid , NoMasterRecordsText %>">
                <CommandItemTemplate>
                    <asp:ImageButton ID="ibtnInitInsert" CausesValidation="false" CommandName="InitInsert" runat="server"
                    ImageUrl="~/Design/images/Grid/AddRecord.gif" />
                    <asp:LinkButton ID="lbtnInitInsert" CausesValidation="false" runat="server" Font-Size="14px"
                        Text="<%$ Resources:MainGrid , AddNew %>" Visible="true" CommandName="InitInsert" />&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:ImageButton ID="ibtnEditSelected" CausesValidation="false" CommandName="EditSelected"
                        runat="server" ImageUrl="~/Design/images/Grid/Edit.gif" />
                    <asp:LinkButton ID="lbtnEditSelected" CausesValidation="false" runat="server" Font-Size="Medium"
                        Text="<%$ Resources:MainGrid , EditSelected %>" Visible="true" CommandName="EditSelected" />&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:ImageButton ID="ibtnDeleteSelected" CausesValidation="false" CommandName="DeleteSelected"
                        OnClientClick="<%$ Resources:MainGrid , OnClientClickDelete %>" runat="server"
                        ImageUrl="~/Design/images/Grid/Delete.gif" />
                    <asp:LinkButton ID="lbtnDeleteSelected" Font-Size="Medium" CausesValidation="false"
                        OnClientClick="<%$ Resources:MainGrid , OnClientClickDelete %>" runat="server"
                        Text="<%$ Resources:MainGrid , DeleteSelected %>" CommandName="DeleteSelected" />&nbsp;&nbsp;&nbsp;&nbsp;
                    <asp:ImageButton ID="ibtnRebindGrid" CausesValidation="false" CommandName="RebindGrid"
                        runat="server" ImageUrl="~/Design/images/Grid/Refresh.gif" />
                    <asp:LinkButton ID="lbtnRebindGrid" Font-Size="Medium" CausesValidation="false" runat="server"
                        Text="<%$ Resources:MainGrid , Refresh %>" CommandName="RebindGrid" />
                </CommandItemTemplate>
                
                <Columns>
                               
                    <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"  ButtonType="ImageButton">
                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    </telerik:GridEditCommandColumn>

                    <telerik:GridBoundColumn DataField="ItemID" HeaderText="ItemID" ReadOnly="True" SortExpression="ItemID"
                        UniqueName="ItemID" Visible="false">
                    </telerik:GridBoundColumn>
                            
                    <telerik:GridBoundColumn DataField="ItemNameAr" meta:ResourceKey="gbcItemNameAr"
                        SortExpression="ItemNameAr" UniqueName="ItemNameAr" >
                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"/>
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    </telerik:GridBoundColumn>

                    <telerik:GridBoundColumn DataField="ItemNameEn" meta:ResourceKey="gbcItemNameEn"
                        SortExpression="ItemNameEn" UniqueName="ItemNameEn"  >
                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    </telerik:GridBoundColumn>

                    <telerik:GridBoundColumn DataField="ItemDesc" meta:ResourceKey="gbcItemDesc"
                        SortExpression="ItemDesc" UniqueName="ItemDesc"  >
                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" />
                    </telerik:GridBoundColumn>
                                                         
                    <telerik:GridBoundColumn DataField="Highlevel" meta:ResourceKey="gbcHighlevel" SortExpression="Highlevel"
                        UniqueName="Highlevel" Visible="true">
                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"  />
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"/>
                    </telerik:GridBoundColumn>

                    <telerik:GridBoundColumn DataField="LowLevel" meta:ResourceKey="gbcLowLevel" SortExpression="LowLevel"
                        UniqueName="LowLevel" Visible="true">
                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle"/>
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle"/>
                    </telerik:GridBoundColumn>

                    <telerik:GridDropDownColumn DataField="ItemCatNo" DataSourceID="odsItemCat" meta:ResourceKey="gbcItemCatNo"
                    ListTextField="ItemCatDesc" ListValueField="ItemCatID"
                    UniqueName="ItemCatNo" EnableEmptyListItem="True">
                    <HeaderStyle Width="100px" />
                    <ItemStyle Width="100px" />
                    </telerik:GridDropDownColumn>
                    <telerik:GridBoundColumn DataField="ItemCatNo"
                        SortExpression="ItemCatNo" UniqueName="ItemCat" Visible="false"/>

                    <telerik:GridBoundColumn DataField="ItemStatus" meta:ResourceKey="gbcItemStatus"
                        SortExpression="ItemStatus" UniqueName="ItemStatus" Visible="true" >
                        <HeaderStyle Width="75px" />
                        <ItemStyle Width="75px" />
                    </telerik:GridBoundColumn>

                    <telerik:GridBoundColumn DataField="IsExpiryDate" meta:ResourceKey="gbcIsExpiryDate"
                        SortExpression="IsExpiryDate" UniqueName="IsExpiryDate" Visible="true">
                        <HeaderStyle Width="50px" />
                        <ItemStyle Width="50px" />
                    </telerik:GridBoundColumn>

                    <telerik:GridButtonColumn UniqueName="DeleteColumn" ConfirmText="<%$ Resources:MainGrid , ConfirmDelete %>" ConfirmTitle="Confirm" ButtonType="ImageButton" CommandName="Delete" >
                        <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                        <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    </telerik:GridButtonColumn>
                    
            </Columns>

            <EditFormSettings ColumnNumber="2" EditFormType="Template" CaptionDataField="BankID"  >
               
                   <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                    <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                    <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                        Width="100%" />
                    <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                    <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                    <EditColumn ButtonType="ImageButton"
                        UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                    </EditColumn>
                    <FormTableButtonRowStyle HorizontalAlign="Left" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                
                
              
              <FormTemplate>
              
              
              <table id="Table2" cellspacing="2" cellpadding="1" border ="0" rules="none" >
                                    
                  <tr style="margin-bottom:40px">
                  <td>
                        <%--<asp:Label ID="lblNewUser" Font-Bold="true" Font-Italic="true" runat="server" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "New User", "Update User") %>' SkinID="KeyLabel"></asp:Label>--%> 
                        
                  </td>
                  </tr>
                  <tr>
                  <td>
                       <asp:Label ID="lblManrtbItemID" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>" ></asp:Label>
                       <asp:Label ID="lblItemID" runat="server" meta:ResourceKey="lblItemID" SkinID="KeyLabel" ></asp:Label>
                       &nbsp;&nbsp;
                  </td>
                  <td>
                       <telerik:RadTextBox ID="rtbItemID" runat="server" Width="250px" 
                        Text='<%# Bind("ItemID") %>' Enabled='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "True", "False") %>' >
                       </telerik:RadTextBox> 
                       <asp:RequiredFieldValidator ID="rfvrtbItemID" runat="server" ControlToValidate="rtbItemID" Display="Dynamic" ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valEditMode"></asp:RequiredFieldValidator>
                       <asp:CustomValidator ID="CVItemID" runat="server" ForeColor="Red" ControlToValidate="rtbItemID" Display="Dynamic" ValidationGroup="valEditMode"
                        ValidateEmptyText="false" OnServerValidate="CVItemID_ServerValidate" ErrorMessage="<%$ Resources:Controls, Exists %>"></asp:CustomValidator> 
                   </td>
                   </tr>
                  <tr>
                  <td>
                       <asp:Label ID="lblManrtbItemNameAr" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>" ></asp:Label>
                       <asp:Label ID="lblItemNameAr" runat="server" meta:ResourceKey="lblItemNameAr" SkinID="KeyLabel" ></asp:Label>
                       &nbsp;&nbsp;
                  </td>
                  <td>
                       <telerik:RadTextBox ID="rtbItemNameAr" runat="server" Width="250px" 
                        Text='<%# Bind("ItemNameAr") %>'>
                       </telerik:RadTextBox> 
                       <asp:RequiredFieldValidator ID="rfvrtbItemNameAr" runat="server" ControlToValidate="rtbItemNameAr" ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valEditMode"></asp:RequiredFieldValidator>
                   </td>
                   <td>
                   </td>
                  <td>
                       <asp:Label ID="lblManrtbItemNameEn" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>" ></asp:Label>
                       <asp:Label ID="lblItemNameEn" runat="server" meta:ResourceKey="lblItemNameEn" SkinID="KeyLabel" ></asp:Label>
                        &nbsp;&nbsp;
                  </td>
                  <td>
                       <telerik:RadTextBox ID="rtbItemNameEn" Width="250px" runat="server" 
                        Text='<%# Bind("ItemNameEn") %>'>
                       </telerik:RadTextBox> 
                       <asp:RequiredFieldValidator ID="rfvrtbItemNameEn" runat="server" ControlToValidate="rtbItemNameEn" ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valEditMode"></asp:RequiredFieldValidator>
                   </td>
                   <td>
                   </td>
                  </tr>


                  <tr>
                  <td>
                       <%--<asp:Label ID="lblManrtbTel" runat="server" SkinID="Mandetory" Text="<%$ Resources:Controls, RequiredValidationText %>" ></asp:Label>--%>
                       <asp:Label ID="lblrtbItemDesc" runat="server" meta:ResourceKey="lblItemDesc" SkinID="KeyLabel"></asp:Label>
                        &nbsp;&nbsp;
                  </td>
                  <td>
                       <telerik:RadTextBox ID="rtbItemDesc" Width="250px" runat="server" 
                        Text='<%# Bind("ItemDesc") %>'>
                       </telerik:RadTextBox> 
                   </td>
                   <td>
                        <%--<asp:RequiredFieldValidator ID="rfvrtbBankAccountNo" runat="server" ControlToValidate="rtbBankAccountNo" ErrorMessage="<%$ Resources:Controls, ErrorMessage %>" ValidationGroup="valEditMode"></asp:RequiredFieldValidator>--%>
                   </td>
                   <td>
                       <asp:Label ID="lblHighlevel" runat="server" meta:ResourceKey="lblHighlevel" SkinID="KeyLabel"></asp:Label>
                        &nbsp;&nbsp;
                  </td>
                  <td>
                       <telerik:RadNumericTextBox ID="rntbHighLevel" Width="100px" runat="server" 
                        Text='<%# Bind("HighLevel") %>'>
                       </telerik:RadNumericTextBox>
                   </td>
                   <td>
                        
                   </td>
                   </tr>
                   <tr>
                  <td>
                        <asp:Label ID="lblLowLevel" runat="server" meta:ResourceKey="lblLowLevel" SkinID="KeyLabel"></asp:Label>
                        &nbsp;&nbsp;
                  </td>
                  <td>
                       <telerik:RadNumericTextBox ID="rntbLowLevel" Width="100px" runat="server" 
                        Text='<%# Bind("LowLevel") %>'>
                       </telerik:RadNumericTextBox>
                       </td>
                       <td>
                            
                       </td>
                       <td>
                           <asp:Label ID="lblItemCatNo" runat="server" meta:ResourceKey="lblItemCatNo" SkinID="KeyLabel"></asp:Label>
                            &nbsp;&nbsp;
                      </td>
                      <td>
                           <uc2:OneFilteredDropDownList ID="rcbItemCatNo" runat="server" DataSourceId="odsItemCat"
                            DataValueField="ItemCatID" IsRequired="false" DataTextField="ItemCatDesc"
                            DefaultChoosedItem="ChooseOne" ValidationGroup="ValEditMode" SelectedValue='<%# Bind("ItemCatNo") %>' />
                       </td>
                       <td>
                        
                       </td>                 
                   </tr>

                   <tr>
                       <td>
                            <asp:Label ID="lblItemStatus" runat="server" meta:ResourceKey="lblItemStatus" SkinID="KeyLabel"></asp:Label>
                            &nbsp;&nbsp;
                      </td>
                      <td >
                           <telerik:RadNumericTextBox ID="rntbItemStatus" Width="100px" runat="server" 
                            Text='<%# Bind("ItemStatus") %>'>
                           </telerik:RadNumericTextBox>
                       </td>
                       <td></td>
                       <td>
                            <asp:Label ID="lblIsExpiryDate" runat="server" meta:ResourceKey="lblIsExpiryDate" SkinID="KeyLabel"></asp:Label>
                            &nbsp;&nbsp;
                      </td>
                      <td >
                           <telerik:RadNumericTextBox ID="rntbIsExpiryDate" Width="100px" runat="server" 
                            Text='<%# Bind("IsExpiryDate") %>'>
                           </telerik:RadNumericTextBox>
                       </td>
                   </tr>


                  <tr>
                   
                   <td colspan="6"> 
                    <div style="margin-top: 15px">
                        <telerik:RadButton ID="btnInsert" meta:ResourceKey="btnInsert" Visible='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "True", "False") %>'
                            runat="server" CommandName="PerformInsert" Icon-PrimaryIconCssClass="rbOk" ValidationGroup="ValEditMode">
                        </telerik:RadButton>
                        <telerik:RadButton ID="btnUpdate" meta:ResourceKey="btnUpdate" Visible='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "False", "True") %>'
                            runat="server" CommandName="Update" CausesValidation="true" ValidationGroup="ValEditMode"
                            Icon-PrimaryIconCssClass="rbOk">
                        </telerik:RadButton>
                        &nbsp;
                        <telerik:RadButton ID="btnCancel" meta:ResourceKey="btnCancel" runat="server" CausesValidation="False"
                            CommandName="Cancel" Icon-PrimaryIconCssClass="rbCancel">
                        </telerik:RadButton>
                    </div>
                   </td>
                 </tr>

        </table>
        
              </FormTemplate>                
   
                </EditFormSettings>

                        <RowIndicatorColumn>
                            <HeaderStyle Width="20px" />
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn>
                            <HeaderStyle Width="20px" />
                        </ExpandCollapseColumn>
                        <HeaderStyle Font-Bold="False" Font-Italic="False" Font-Overline="False" Font-Strikeout="False"
                            Font-Underline="False" HorizontalAlign="Center" Wrap="True"   />
                    </MasterTableView>
                    <ValidationSettings CommandsToValidate="PerformInsert,Update" ValidationGroup="valEditMode" />
                    <ClientSettings AllowDragToGroup="False">
                        <Scrolling AllowScroll="false" ScrollHeight="400px"   />
                        <Selecting AllowRowSelect="True" />
                    </ClientSettings>
                    <FilterMenu EnableTheming="True">
                        <CollapseAnimation Duration="200" Type="OutQuint" />
                    </FilterMenu>
                     <PagerStyle Mode="NextPrevAndNumeric"></PagerStyle>
                </telerik:RadGrid>


        <asp:ObjectDataSource ID="odsItem" runat="server" 
            DeleteMethod="QueryDatabase" InsertMethod="QueryDatabase" 
            SelectMethod="QueryDatabase" TypeName="DBItemSP" 
            UpdateMethod="QueryDatabase">
            <DeleteParameters>
                <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
                <asp:Parameter DefaultValue="DeleteItem" Name="Operation" Type="String" />
                <asp:Parameter Name="ItemID" Type="String" />
                <asp:Parameter Name="ItemNameAr" Type="String" />
                <asp:Parameter Name="ItemNameEn" Type="String" />
                <asp:Parameter Name="ItemDesc" Type="String" />
                <asp:Parameter Name="Highlevel" Type="String" />
                <asp:Parameter Name="LowLevel" Type="String" />
                <asp:Parameter Name="ItemCatNo" Type="String" />
                <asp:Parameter Name="ItemStatus" Type="String" />
                <asp:Parameter Name="IsExpiryDate" Type="String" />
            </DeleteParameters>
            <InsertParameters>
                <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
                <asp:Parameter DefaultValue="SaveItem" Name="Operation" Type="String" />
                <asp:Parameter Name="ItemID" Type="String" />
                <asp:Parameter Name="ItemNameAr" Type="String" />
                <asp:Parameter Name="ItemNameEn" Type="String" />
                <asp:Parameter Name="ItemDesc" Type="String" />
                <asp:Parameter Name="Highlevel" Type="String" />
                <asp:Parameter Name="LowLevel" Type="String" />
                <asp:Parameter Name="ItemCatNo" Type="String" />
                <asp:Parameter Name="ItemStatus" Type="String" />
                <asp:Parameter Name="IsExpiryDate" Type="String" />
            </InsertParameters>
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
                <asp:Parameter DefaultValue="RtvItem" Name="Operation" Type="String" />
                <asp:Parameter Name="ItemID" Type="String" />
                <asp:Parameter Name="ItemNameAr" Type="String" />
                <asp:Parameter Name="ItemNameEn" Type="String" />
                <asp:Parameter Name="ItemDesc" Type="String" />
                <asp:Parameter Name="Highlevel" Type="String" />
                <asp:Parameter Name="LowLevel" Type="String" />
                <asp:Parameter Name="ItemCatNo" Type="String" />
                <asp:Parameter Name="ItemStatus" Type="String" />
                <asp:Parameter Name="IsExpiryDate" Type="String" />
            </SelectParameters>
            <UpdateParameters>
                <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
                <asp:Parameter DefaultValue="SaveItem" Name="Operation" Type="String" />
                <asp:Parameter Name="ItemID" Type="String" />
                <asp:Parameter Name="ItemNameAr" Type="String" />
                <asp:Parameter Name="ItemNameEn" Type="String" />
                <asp:Parameter Name="ItemDesc" Type="String" />
                <asp:Parameter Name="Highlevel" Type="String" />
                <asp:Parameter Name="LowLevel" Type="String" />
                <asp:Parameter Name="ItemCatNo" Type="String" />
                <asp:Parameter Name="ItemStatus" Type="String" />
                <asp:Parameter Name="IsExpiryDate" Type="String" />
            </UpdateParameters>
        </asp:ObjectDataSource>


        <asp:ObjectDataSource ID="odsItemCat" runat="server" SelectMethod="QueryDatabase"
        TypeName="DBItemCatSP">
            <SelectParameters>
                <asp:Parameter DefaultValue="1" Name="QueryType" Type="Object" />
                <asp:Parameter DefaultValue="RtvItemCat" Name="Operation" Type="String" />
                <asp:Parameter Name="ItemCatID" Type="String" />
                <asp:Parameter Name="ItemCatDesc" Type="String" />
            </SelectParameters>
        </asp:ObjectDataSource>




</asp:Content>

